package day12;

/**
 * @author oldliu
 * @since 1.0
 */
public class Calc {

    public  int add(int a,int b){
        return a+b;
    }
    public  int mul(int a,int b)throws RuntimeException{
        if(a==0||b==0)
            throw new RuntimeException("怎么是0？");
        return a*b;
    }
    //鑫半除法
    public int div(int a,int b)throws Exception{
        try {
            int c=a/b;
            return c;
        } catch (Exception e) {
            e.printStackTrace();
            //throw e;//抛出异常，也算是一种返回值
            throw new Exception("除数是0是错误的！",e);
        }
    }

    //除法
//    public int div(int a,int b){
//        try {
//            int c=a/b;
//            return c;
//        } catch (Exception e) {
//           //>>>e.printStackTrace();
//        }
//        return 0;
//    }
}
